#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <set>
#include <map>
#include <iostream>
#define mn 20
using namespace std;
class Solution {
public:
    int zt[mn][mn];
    string myinit(string s)
    {
        for (int i = 0; i < mn; i++)
            for (int j = 0; j < mn; j++)
                zt[i][j] = -1;
        zt[0][0] = 2;   zt[0][5] = 7;
        zt[1][0] = 1;   zt[1][2] = 1;   zt[1][3] = 4;   zt[1][5] = 6;   zt[1][7] = 6;   zt[1][10] = 4; zt[1][11] = 9;
        zt[2][1] = 5;   zt[2][3] = 5;   zt[2][4] = 5;
        zt[3][0] = 10;  zt[3][1] = 3;   zt[3][2] = 10;
        zt[4][0] = 0;   zt[4][1] = 9;   zt[4][3] = 9;   zt[4][4] = 9;   zt[4][6] = 9;   zt[4][9] = 9;
        string str = "";
        for (char c : s)
        {
            if (c >= '0' && c <= '9')
            {
                if (str.size() && str.back() == 'd') continue;
                else str.push_back('d');
            }
            else str.push_back(c);
        }
        return str;
    }
    int zh(char c)
    {
        if (c == '-' || c == '+')return 0;
        if (c == 'd')return 1;
        if (c == 'e')return 2;
        if (c == '.')return 3;
        if (c == ' ' || c == '\t' || c == '\n') return 4;
        return 5;
    }
    bool isNumber(string s) {
        s = myinit(s);
        int now = 0;
        for (char c : s)
        {
            now = zt[zh(c)][now];
            if (now == -1)return 0;
        }
        return (now == 1 || now == 3 || now == 4 || now == 6 || now == 9);
    }
};